import { request } from "@/utils/request";

export interface UserInfo {
  isShowNeedBtn?: boolean;
  id?: number;
  avatar?: string;
  nickname?: string;
  cheese?: string;
  integral?: string;
  is_admin?: number;
  lawyer_joblevel?: string;
  phone?: string;
  realname?: string;
  user_level?: {
    id: number;
    level: string;
    status: number;
  }
}

/** 获取当前的用户信息 GET /api/user/info */
export async function currentUser() {
  return request<UserInfo>("/api/user/info", {
    method: "GET",
  });
}

/** 更新个人资料 POST /api/user/save */
export async function postUserInfo(data: Record<string, any>) {
  return request<UserInfo>("/api/user/save", {
    method: "POST",
    data,
  });
}

/** 获取个人资料明细 GET /api/user/information */
export async function getUserDetail() {
  return request<UserInfo>("/api/user/information", {
    method: "GET",
  });
}

/** 更新个人资料明细 GET /api/user/information/save */
export async function postUserDetail(data: Record<string, any>) {
  return request<UserInfo>("/api/user/information/save", {
    method: "POST",
    data
  });
}

/** 退出登录接口 POST /api/user/logout */
export async function outLogin() {
  return request("/api/user/logout", {
    method: "POST",
  });
}

/** 登录接口 POST /api/user/login */
export async function login(data: Record<string, any>) {
  return request("/api/user/login", {
    method: "POST",
    data,
  });
}

/** 微信登录接口 POST /api/login/login */
export async function weChatLogin(data: Record<string, any>) {
  return request("/api/login/login", {
    method: "POST",
    data,
  });
}


export interface IntegralInfo {
  remark: string;
  created_at: string;
  integral: string;
  type: number;
  [key: string]: any;
}

/** 获取水滴记录 GET /api/integral/list */
export async function getIntegralList(params: Record<string, any>) {
  return request<API.PagedList<IntegralInfo>>(`/api/integral/list`, {
    method: "GET",
    params,
  });
}

/** 获取水滴记录 GET /api/cheese/list */
export async function getCheeseList(params: Record<string, any>) {
  return request<API.PagedList<IntegralInfo>>(`/api/cheese/list`, {
    method: "GET",
    params,
  });
}

/** 获取邀请记录 GET /api/invite/list */
export async function getInviteList(params: Record<string, any>) {
  return request<API.PagedList<any>>(`/api/invite/list`, {
    method: "GET",
    params,
  });
}

/** 获取兑换记录 GET /api/user/order/list */
export async function getOrderList(params: Record<string, any>) {
  return request<API.PagedList<any>>(`/api/user/order/list`, {
    method: "GET",
    params,
  });
}


/** 获取收藏列表 GET /api/user/collect/list */
export async function getCollectList(params: Record<string, any>) {
  return request<API.PagedList<any>>(`/api/user/collect/list`, {
    method: "GET",
    params,
  });
}
